package cn.apestar.common.huanxin;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

public class Message implements Runnable{

	String userIds;
	
	String type;
	
	String message;
	
	// 1 普通系统消息 2 抢到消息
	String messageType;
	
	public Message(String userIds,String message,String messageType){
		this.userIds = userIds;
		this.type = type;
		this.message = message;
		this.messageType = messageType;
		
	}
	
	public String getUserIds() {
		return userIds;
	}

	public void setUserIds(String userIds) {
		this.userIds = userIds;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getMessageType() {
		return messageType;
	}

	public void setMessageType(String messageType) {
		this.messageType = messageType;
	}

	@Override
	public void run() {
		// TODO Auto-generated method stub
		String[] s1 = userIds.split(",");
		if(s1.length < 20){
			huanXinUtil.transmissionMessageByone(userIds, message, type,messageType);	
		}else{
			int m = s1.length;
			int n = 0;
			List list = Arrays.asList(s1);
			while (n < m) {
				int max = n + 20;
				if(max > m){
					max = m;
				}
				List listTrans = list.subList(n, max);
				n = n + 20;
				String s = "'1'";
				for (int i = 0; i < listTrans.size(); i++) {
					Map r2 = (Map) listTrans.get(i);
					s += "," + r2.get("id");
				}
				huanXinUtil.transmissionMessageByone(s, message,type,messageType);
			}
		}
	}

}
